package com.phrp.controller;

import com.phrp.entity.House;
import com.phrp.service.HouseService;
import com.phrp.entity.vo.HouseSearchDataVo;
import com.phrp.entity.vo.PageData;
import com.phrp.util.returnResult.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.LinkedList;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ssc
 * @since 2024-04-20
 */
@RestController
@RequestMapping("/house")
public class HouseController {

    @Autowired
    private HouseService houseService;

    /**
     * 获取房源信息
     * @param pageData
     * @return
     */
    @PostMapping("getHouseSource")
    public ResponseResult getHouseSource(@RequestBody PageData pageData){
        return houseService.getHouseSource(pageData);
    }

    /**
     * 删除房源信息
     * @param ids
     * @return
     */
    @PostMapping(value = "deleteHouse")
    public ResponseResult deleteHouse(@RequestBody LinkedList<String> ids){
        return houseService.deleteHouse(ids);
    }

    /**
     * 修改房源信息
     * @param house
     * @return
     */
    @PostMapping(value = "editHouse")
    public ResponseResult editHouse(@RequestBody House house){
        return houseService.editHouse(house);
    }

    /**
     * 新增房源信息
     * @param house
     * @return
     */
    @PostMapping(value = "AddHouse")
    public ResponseResult AddHouse(@RequestBody House house){
        return houseService.AddHouse(house);
    }

    /**
     * 更新发布状态
     * @param id,type
     * @return
     */
    @GetMapping(value = "updatePublish")
    public ResponseResult updatePublish(@RequestParam String id,@RequestParam String type){
        return houseService.updatePublish(id,type);
    }

    /**
     * 更新状态
     * @param id,type
     * @return
     */
    @GetMapping(value = "updateStatus")
    public ResponseResult updateStatus(@RequestParam String id,@RequestParam String type){
        return houseService.updateStatus(id,type);
    }

    /**
     * 根据条件进行搜索
     * @return
     */
    @PostMapping(value = "searchHouse")
    public ResponseResult searchHouse(@RequestBody HouseSearchDataVo searchData){
        return houseService.searchHouse(searchData);
    }

    /**
     * 获取巡查数据
     * @return
     */
    @PostMapping(value = "inspectionSearch")
    public ResponseResult inspectionSearch(@RequestBody HouseSearchDataVo houseSearch){
        return houseService.inspectionSearch(houseSearch);
    }

}
